package cn.sys.util;

import java.util.HashMap;

/**
 *   自定义的响应结果集对象
 *   修改为Map集合，方便取值
 */

public class ResultData extends HashMap {

    /**
     * 响应给前端的编码
     */
    //private int code;

    /**
     * 响应提示信息
     *      比如 修改成功、修改失败 这样的信息
     */
    //private String msg;

    /**
     * 响应数据
     *      封装着响应给前端的数据
     */
    //private Object data;

    /**
     *自定义的操作成功的业务状态码
     */
    public static final int  OPERATION_SUCCESS = 10001;

    /**
     *自定义的操作失败的业务状态码
     */
    public static final int  OPERATION_FAIL = 10002;

    /**
     * 自定义登录成功的业务状态码
     */
    public static final int LOGIN_SUCCESS = 20001;

    /**
     * 自定义登录失败的业务状态码
     */
    public static final int LOGIN_FAIL = 20002;

    /**
     * 自定义密保验证成功的状态码
     */
    public static final int CHECK_SECURITY_QUESTION_SUCCESS = 30001;

    /**
     * 自定义密保验证失败的状态码
     */
    public static final int CHECK_SECURITY_QUESTION_FAIL = 30002;

    /**
     * 自定义账号未冻结的状态码
     */
    public static final int STUDENT_UNLOCK_STATE = 40001;

    /**
     * 自定义账号冻结的状态码
     */
    public static final int STUDENT_LOCKED_STATE = 40002;

    /**
     * 自定义查询宿舍信息成功的状态码
     */
    public static final int DORMITORY_INFO_NOT_EMPTY = 50001;
    /**
     * 自定义宿舍信息为空的状态码
     */
    public static final int DORMITORY_INFO_EMPTY = 50002;

    /**
     * 自定义公告删除成功的状态码
     */
    public static final int DELETE_NOTICE_SUCCESS = 60001;

    /**
     * 自定义公告删除失败的状态码
     */
    public static final int DELETE_NOTICE_FAIL = 60002;



    public ResultData(){}

    public ResultData(int code, String msg, Object data) {
        this.put("code",code);
        this.put("msg",msg);
        this.put("data",data);
        /*this.code = code;
        this.msg = msg;
        this.data = data;*/
    }


    /**
     * 操作成功，并且没有数据时，直接响应给前端的ResultData
     * @return
     */
    public static ResultData ok(){
        return new ResultData(OPERATION_SUCCESS,"操作成功",null);
    }

    public static ResultData ok(int code, String msg){
        return new ResultData(code,msg,null);
    }

    /**
     * 操作失败，并且没有数据时，直接响应给前端的ResultData
     * @return
     */
    public static ResultData fail(){
        return new ResultData(OPERATION_FAIL,"操作失败",null);
    }

    public static ResultData fail(int code, String msg){
        return new ResultData(code,msg,null);
    }

    /**
     * 封装数据给前端的  ResultData
     */
    public static ResultData createData(int code,Object data){
        return new ResultData(code,null,data);
    }




    /*public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }*/
}
